import Vue from "vue";
import {request} from "../../../util/request.js";
import "../../../style/basic.less";
import dialog from "../../../util/dialog.js";
new Vue({
    el:"#louie",
    data:{
        auto_cash:"",
        lowest_cash:"",
        cash_remark:"",
        use_balance:"1"
    },
    computed:{
        data:function(){
            return {
                auto_cash:this.auto_cash,
                lowest_cash:this.lowest_cash,
                cash_remark:this.cash_remark,
                use_balance:this.use_balance
            }
        }
    },
    created:function(){
        this.get();
    },
    methods:{
        /**
         * 获取参数
         */
        get(){
            request("setting/easyFind",{
                return:["auto_cash","lowest_cash","cash_remark","use_balance"]
            })
                .then((res)=>{
                    window.console.log(res);
                    if(res.data.status === "success"){
                        let data = res.data.data;
                        this.auto_cash = data.auto_cash;
                        this.lowest_cash = data.lowest_cash;
                        this.cash_remark = data.cash_remark;
                        this.use_balance = data.use_balance;
                    }
                });
        },
        /**
         * 设置参数
         */
        submit(){
           request("setting/set",{
               data:this.data
           })
               .then((res)=>{
                   if(res.data.status === "success"){
                       dialog.alert(this,"设置成功");
                   }else{
                       dialog.alert(this,"设置失败");
                   }
               });
        }
    }
});